package com.cndw.kungfu.dao;

import java.util.List;

import com.cndw.dao.jade.annotation.DAO;
import com.cndw.dao.jade.annotation.SQL;
import com.cndw.dao.jade.annotation.SQLParam;

import com.cndw.kungfu.domain.TaskMode;

@DAO
public interface TaskModeDao {
	
	public static final String TABLE = " kfsys_task ";
	
	public static final String FIELDS = " taskId,name,description,type,classId,level,levelMax,color,sourceNpcId,targetNpcId,frontTaskId,acceptConditions,submitConditions,playerExp,playerAsset,playerGoldTicke,prestige,unionAsset,unionGest,unionDedicate,allRewards,oneRewards,acceptText,submitText,unCompleteText,storyOnSubmit,giveItem,timesLimit,fastPay,showInfo ";
	
	
	/**
	 * 获取任务数据
	 * @param id
	 * @return
	 */
	@SQL("select "+FIELDS + " from " + TABLE + " where taskId=:id;")
	public TaskMode get(@SQLParam("id")int taskId);	
	
	
	/**
	 * 获取当前屏幕npc的任务
	 * @param sourceNpcId
	 * @param type
	 * @return
	 */
	@SQL("select "+FIELDS + " from " + TABLE + " where type=:type and sourceNpcId in (:sourceNpcId) ;")
	public List<TaskMode> getTasksByNpcIds(
			@SQLParam("sourceNpcId") String sourceNpcId);
	
	/**
	 * 获得某个npc的可接任务
	 * @param sourceNpcId
	 * @param type
	 * @return
	 */
	@SQL("select "+FIELDS + " from " + TABLE + " where type=:type and sourceNpcId=:sourceNpcId ;")
	public List<TaskMode> getTasksByOneNpc(
			@SQLParam("sourceNpcId") int sourceNpcId);	
	
	
	@SQL("select  "+FIELDS + " from " + TABLE + " a where level <=:level " +
			" and not exists (select 1 from kf_player_task c where a.taskId=c.taskId and playerId=:playerId and c.status=:excludedStatus ) ")
	public List<TaskMode> getNpcsTasks(
			@SQLParam("playerId") long playerId,
			@SQLParam("level") int level,
			@SQLParam("excludedStatus") int excludedStatus);
	
	
	@SQL("select  "+FIELDS + " from " + TABLE + " order by taskId asc ")
	public List<TaskMode> getAllTasksFromDb();
	
	
}
